//
//  LWZListCell.m
//  MusicFM
//
//  Created by 王景欣 on 16/1/12.
//  Copyright © 2016年 LWZ. All rights reserved.
//

#import "LWZListCell.h"

@interface LWZListCell ()

@property (nonatomic ,strong) UIImageView *coverPathImageView;

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UILabel *firstKResultsLabel;

@property (nonatomic, strong) UILabel *firstKResultsLabelTwo;

@end

@implementation LWZListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
       
        [self creatUI];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.coverPathImageView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.edges.equalTo(self).insets(UIEdgeInsetsMake(25, 20, 25, kScreenWidth * 2 / 3));
        make.top.offset(20);
        make.bottom.offset(-20);
        make.left.offset(10);
        make.width.mas_equalTo(kScreenWidth / 3 - 20);

    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(20);
        make.centerX.equalTo(@[self.firstKResultsLabel, self.firstKResultsLabelTwo]);
        make.left.offset(kScreenWidth / 3);
        make.size.mas_equalTo(CGSizeMake(kScreenWidth * 2 / 3 - 10, 20));
    }];
    
    [self.firstKResultsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(self.height / 3);
        make.size.mas_equalTo(CGSizeMake(kScreenWidth * 2 / 3 - 10, 10));
    }];
    
    [self.firstKResultsLabelTwo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(self.height / 2);
        make.size.mas_equalTo(CGSizeMake(kScreenWidth * 2 / 3 - 10, 10));
    }];
}

- (void)setListModel:(LWZFmListModel *)listModel {
    if (_listModel != listModel) {
        _listModel = listModel;
    }
    [self.coverPathImageView yy_setImageWithURL:[NSURL URLWithString:self.listModel.coverPath] placeholder:[UIImage imageNamed:@"IMG_1396"]];
    self.titleLabel.text = self.listModel.title;
    self.firstKResultsLabel.text = [NSString stringWithFormat:@"1  %@",self.listModel.firstTitle];
    self.firstKResultsLabelTwo.text = [NSString stringWithFormat:@"2  %@",[[self.listModel.firstKResults lastObject] valueForKey:@"title"]];
}

- (void)creatUI {
    self.coverPathImageView = [UIImageView new];
    self.coverPathImageView.layer.cornerRadius = 5;
    self.coverPathImageView.layer.masksToBounds = YES;
    [self addSubview:self.coverPathImageView];
    
    self.titleLabel = [UILabel new];
    self.titleLabel.textColor = [UIColor blackColor];
    [self addSubview:self.titleLabel];
    
    self.firstKResultsLabel = [UILabel new];
    self.firstKResultsLabel.textColor = [UIColor blackColor];
    self.firstKResultsLabel.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.firstKResultsLabel];
    
    self.firstKResultsLabelTwo = [UILabel new];
    self.firstKResultsLabelTwo.textColor = [UIColor blackColor];
    self.firstKResultsLabelTwo.font = [UIFont systemFontOfSize:13];
    [self addSubview:self.firstKResultsLabelTwo];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
